package com.example.administrator.kotlintabviewpagerfragment.fragment

import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.widget.LinearLayoutManager
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.example.administrator.kotlintabviewpagerfragment.R
import com.example.administrator.kotlintabviewpagerfragment.adapter.RecChlidAdapter
import kotlinx.android.synthetic.main.child_tab_fragment1.view.*
import org.jetbrains.anko.support.v4.toast

/**
 * Created by sswl on 2017/7/7.
 */
class TabChildFragment1 : Fragment() ,RecChlidAdapter.OnItemClickListener{
    /**
     * item 点击事件
     * */
    override fun onClick(position: Int) {
        toast("我是Item  position${position}")
    }

    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        val view = inflater!!.inflate(R.layout.child_tab_fragment1, container, false)
        view.mRec.layoutManager= LinearLayoutManager(activity)
        val adapter = RecChlidAdapter(activity, mList()!!)
        view.mRec.adapter=adapter
        adapter.setOnClick(this)
        return view
    }
    fun mList(): ArrayList<String>{
        var mList= ArrayList<String>()
        for (x : Int in 0..30){
            mList.add(""+x)
        }
        return mList
    }
}